<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun(){
				var img=document.querySelector("div>img");
				var text=document.querySelector("div>h1");
				if(text.innerText=="灯灭了"){
					img.setAttribute("src","img/on.png");
					text.innerText="灯亮了";
					text.setAttribute("style","color:red;")
				}else{img.setAttribute("src","img/off.png");
					text.innerText="灯灭了";
					text.setAttribute("style","color:black;")
					
				}
			}
		</script>
	</head>
	<body>
		<div style="text-align: center;" onclick="fun()">
			<img src="img/off.png" width="200px">
			<h1 >灯灭了</h1>
		</div>
	</body>
</html>
